package o;

import android.content.Context;
import android.content.Intent;
import com.huawei.appgallery.foundation.application.pkgmanage.model.update.ApkUpgradeInfo;
import com.huawei.appgallery.packagemanager.api.bean.ManagerTask;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appgallery.wishlist.api.RealizedWishInfo;
import com.huawei.appmarket.service.predownload.thread.PreDownloadManagerThread;

public class edz implements coi {
    private ApkUpgradeInfo ˊ;
    private int ˎ;

    public edz(ApkUpgradeInfo apkUpgradeInfo, int i) {
        this.ˊ = apkUpgradeInfo;
        this.ˎ = i;
    }

    public void ॱ(ManagerTask managerTask, int i, int i2) {
    }

    public void ˋ(ManagerTask managerTask, int i, int i2) {
        if (i == 4 || i == 5 || i == 12 || i == 13 || i == 15) {
            ((eeb) PreDownloadManagerThread.ˊ.get(Integer.valueOf(this.ˎ))).ˏ.decrementAndGet();
        }
        if (managerTask != null) {
            euc.ˊ().ॱ();
            Intent intent = new Intent(dvq.ˊ());
            intent.setPackage(ContentManager.getInstant().getContext().getPackageName());
            ContentManager.getInstant().getContext().sendBroadcast(intent);
            Logger.ˎ("PreDldInsCall", this.ˎ + " status view type:" + i + ",pkg:" + managerTask.packageName);
            switch (i) {
                case 4:
                    ˊ(managerTask, i2);
                    break;
                case 5:
                    ˊ(managerTask);
                    break;
                case 12:
                    Logger.ˎ("PreDldInsCall", "INSTALL_FAILED_SELF_CHECKING ");
                    if (this.ˊ != null) {
                        eub.ˎ().ˎ(this.ˊ.ᐝ(), this.ˊ.ʿ());
                        break;
                    }
                    break;
            }
            euc.ˊ().ˏ();
        }
    }

    private void ˊ(ManagerTask managerTask, int i) {
        if (-10009 == i) {
            Logger.ˎ("PreDldInsCall", "app running foreground, can not install now. packageName = " + managerTask.packageName);
            ((edx) cdb.ॱ(edx.class)).ˊ(managerTask.packageName);
        } else if (-10013 == i) {
            Logger.ˎ("PreDldInsCall", "app running foreground service, can not install now. packageName = " + managerTask.packageName);
            ((edx) cdb.ॱ(edx.class)).ˏ("052", managerTask.packageName);
        } else if (-10012 == i) {
            Logger.ˎ("PreDldInsCall", "music is playing, can not install now. packageName = " + managerTask.packageName);
            ((edx) cdb.ॱ(edx.class)).ˏ("056", managerTask.packageName);
        } else if (-10011 == i) {
            Logger.ˎ("PreDldInsCall", "game app is running, can not install now. packageName = " + managerTask.packageName);
            ((edx) cdb.ॱ(edx.class)).ˋ(managerTask.packageName, euv.ˊ());
        } else if (-1000001 != i) {
            ˋ(managerTask, i);
        }
    }

    private void ˊ(ManagerTask managerTask) {
        int i = 2;
        eeb o_eeb = (eeb) PreDownloadManagerThread.ˊ.get(Integer.valueOf(this.ˎ));
        if (o_eeb != null) {
            o_eeb.ॱ.incrementAndGet();
        }
        if (dhq.ॱ().ˎ()) {
            eba ॱ = eba.ॱ(new IServerCallBack(this) {
                final /* synthetic */ edz ˎ;

                {
                    this.ˎ = r1;
                }

                public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
                }

                public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                    if (responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0 && (this.ˎ.ˊ instanceof RealizedWishInfo)) {
                        eny.ˊ().ˏ(ContentManager.getInstant().getContext(), (RealizedWishInfo) this.ˎ.ˊ);
                    }
                }
            });
            Context ˋ = ContentManager.getInstant().getContext();
            String str = managerTask.packageName;
            if (managerTask.ᐝ != 2) {
                i = 1;
            }
            ॱ.ˏ(ˋ, str, null, i, managerTask.ʻ);
            return;
        }
        Logger.ˎ("PreDldInsCall", "install success, can not run bkg report");
    }

    private void ˋ(ManagerTask managerTask, int i) {
        if (dhq.ॱ().ˎ()) {
            new eax(managerTask, i, true).start();
        } else {
            Logger.ˎ("PreDldInsCall", "install failed, can not run bkg report");
        }
        if (this.ˊ != null) {
            eub.ˎ().ˎ(this.ˊ.ᐝ(), this.ˊ.ʿ());
        }
    }
}
